import { v4 as uuidv4 } from 'uuid';
import { Seeder } from '../../umzug';

const conclusionsOne = [{ name: '躯体化', fk: 1 }];

const conclusionsTwo = [
  { name: '焦虑', fk: 2 },
  { name: '抑郁', fk: 2 },
  { name: '偏执', fk: 2 },
  { name: '精神病性', fk: 2 },
  { name: '主观幸福感', fk: 2 },
];

const conclusionsThree = [
  { name: '工作负荷', fk: 3 },
  { name: '公司管理', fk: 3 },
  { name: '与领导关系', fk: 3 },
  { name: '与同事关系', fk: 3 },
  { name: '与客户关系', fk: 3 },
  { name: '与家庭关系', fk: 3 },
];

const conclusionsFour = [
  { name: '应对方式', fk: 4 }
];

const conclusions = [
  ...conclusionsOne,
  ...conclusionsTwo,
  ...conclusionsThree,
  ...conclusionsFour
];

const newConclusions = conclusions.map((item, index) => (
  {
    id: index + 1,
    uuid: uuidv4(),
    name: item.name,
    fk_classification: item.fk,
    created_at: new Date(),
    updated_at: new Date()
  }
));

export const up: Seeder = async ({ context: sequelize }) => {
  await sequelize
    .getQueryInterface()
    .bulkInsert('conclusions', newConclusions);
};

export const down: Seeder = async ({ context: sequelize }) => {
  await sequelize
    .getQueryInterface()
    .bulkDelete(
      'conclusions',
      { id: newConclusions.map((u) => u.id) }
    );
};
